package com.igeek.compus.test.user.entity;

import java.util.Date;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;

@Data
public class User {

    private Integer id;

    private String nickName;

    private String phone;

//    1-男、0-女
    private Integer sex;

    private Integer age;

    private String email;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastTime;

    // 状态：0-正常 1-异常
    private Integer status;

    private Integer page;// 前端传多少页
    private Integer limit;// 每页展示多少条数据
    private Integer pageIndex;

    public Integer getPageIndex() {
        if(page != null && limit != null) {
            return (page - 1) * limit;
        }
        return pageIndex;
    }

    @Override
    public String toString() {
        return "User{" +
                "id=" + id +
                ", nickName='" + nickName + '\'' +
                ", sex='" + sex + '\'' +
                ", phone='" + phone + '\'' +
                ", age=" + age +
                ", email='" + email + '\'' +
                ", createTime=" + createTime +
                ", lastTime=" + lastTime +
                ", status=" + status +
                '}';
    }

}
